function login() {
	$("#login-info").fadeOut();
	$('#page-login-btn').attr("disabled", true);
	$.post("ajax_login", $('#login-form').serialize(), function(data, status) {
		if (status == 'success') {
			if (data.type == 0) {
				if($('#referer').val()!=''){
					location.href = $('#referer').val();
				}else{
					location.href = 'Index';
				}
				$('#page-login-btn').attr("disabled", false);
			} else {
				$("#login-info").text(data.msg);
				$("#login-info").fadeIn();
				$('#page-login-btn').attr("disabled", false);
			}
		} else {
			$("#login-info").text('未知错误：' + status);
			$("#login-info").fadeIn();
			$('#page-login-btn').attr("disabled", false);
		}
		$('#page-login-vcode-img').click();
	});
}

$(document).ready(
		function() {
			var showPassWord = false;
			$('#page-login-vcode-img').bind(
					'click',
					function() {
						$('#page-login-vcode-img').attr('src',
								'get_verification_code?i=' + Math.random());
					});
			$('#password-icon').click(function() {
				if (showPassWord) {
					showPassWord = false;
					$('#password-icon').css('color', '#AAA');
					$('#password').attr('type', 'password');
				} else {
					showPassWord = true;
					$('#password-icon').css('color', '#39A9CF');
					$('#password').attr('type', 'text');
				}
			});

			$('#page-login-btn').click(login);
			$(document).keydown(function(event) {
				if (event.keyCode == 13) {
					login();
				}
			});
		});